using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Reflection;

namespace Fan.Dongping.Common
{
    /// <summary>
    /// utility case
    /// </summary>
    public class Utilities
    {
        /// <summary>
        /// Check Database Connection
        /// </summary>
        /// <param name="connectionString"></param>
        /// <returns></returns>
        public static bool CheckDatabaseConnection(string connectionString)
        {
            SqlConnectionStringBuilder bu = new SqlConnectionStringBuilder(connectionString);
            SqlConnection con = new SqlConnection(connectionString);
            try
            {
                con.Open();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static string GetVersion()
        {
            return Assembly.GetExecutingAssembly().GetName().Version.ToString();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static string GetCopyright()
        {
            object[] os = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
            if (os.Length > 0)
            {
                AssemblyCopyrightAttribute aca = os[0] as AssemblyCopyrightAttribute;
                return aca.Copyright;

            }
            else
            {
                return string.Empty;
            }
        }

    }
}
